#ifndef SOUNDBASE_H
#define SOUNDBASE_H

#include <QObject>
#include <QByteArray>
#include <QUrl>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>

#define URL_TOKEN    "https://aip.baidubce.com/oauth/2.0/token"
#define URL_CREATE   "https://aip.baidubce.com/rpc/2.0/aasr/v1/create"
#define URL_QUERY    "https://aip.baidubce.com/rpc/2.0/aasr/v1/query"

class SoundBase : public QObject
{
    Q_OBJECT
public:
    explicit SoundBase(QObject *parent = nullptr);

    QString getAccessTokenUrl(QString apiId, QString secretKey);
    QString getHead();
    QString getAccessToken(QString apiId, QString secretKey);
signals:

private slots:
    void replyFinish(QNetworkReply * reply);

protected:
    QString paraseAccessToken(QString jsonString);
    QByteArray post(QNetworkRequest request,QByteArray btArray);
protected:
    QString API_access_token;
    QString API_id;
    QString API_key;
    QString API_secret_key;
    QString API_record_path;
    QString API_language;

    QNetworkAccessManager *m_manager;
    QNetworkRequest *m_req;
};

#endif // SOUNDBASE_H
